{% extends "base/base.html" %}

{% comment %}

 Copyright 2013 - Tom Alessi

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and 
 limitations under the License.

{% endcomment %}

{% block content %}

<div class="row">
  <div class="large-9 columns">
    <p>This page contains all relevant information on this scheduled maintenance.  Check back here at any time to obtain current information on the status of this scheduled maintenance.</p>
  </div>
  <div class="large-3 columns"></div>
</div>

<div class="row">
  <div class="large-12 columns">
    <table class="responsive standard">
      <thead>
        <tr>
          <th colspan="2">Maintenance Details</th>
        </tr>
      </thead>
       
      <tbody>
        <tr>
          <td width="165">Maintenance Status</td>
          <td width="565">
            <b>
            {% if detail.0.completed %}
              COMPLETED
            {% else %}
              {% if detail.0.started %}
                STARTED
              {% else %}
                NOT STARTED
              {% endif %}
            {% endif %}
            </b>
          </td>
        </tr>
        <tr>       
          <td>Services Impacted</td>
          <td>
           {% if services %}
           {% for row in services %}
           {{row.service_name_id__service_name}}
            <br>
           {% endfor %}
           {% else %}
           <b><font color="red">- NO SERVICES DEFINED</font></b>
           {% endif %}
          </td>
        </tr>
        <tr>
          <td>Start Time*</td>
          <td>{{detail.0.start|date:"Y-m-d H:i"}}</td>
        </tr>
        <tr>
          <td>End Time*</td>
          <td>{{detail.0.end|date:"Y-m-d H:i"}}</td>
        </tr>
        <tr>
          <td>Description</td>
          <td>{{detail.0.description|linebreaksbr}}</td>
        </tr>
        <tr>
          <td>Impact Analysis</td>
          <td>{{detail.0.impact|linebreaksbr}}</td>
         </tr>
        <tr>
          <td>Coordinator</td>
          <td>{{detail.0.coordinator|linebreaksbr}}</td>
        </tr>
        <tr>
          <td>Email Notifications:{% if not notifications == 1 %}<br><font class="disabled">(disabled)</font>{% endif %}</td>
          <td>{% if detail.0.email_address_id__email_address %}{{detail.0.email_address_id__email_address}}{% else %}No recipient defined{% endif %}</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

{% if updates %}
<div class="row">
  <div class="large-12 columns" style="height: 25px;">
  </div>
</div>

<div class="row">
  <div class="large-12 columns">
    <table class="responsive standard">
      <thead>
        <tr>
          <th colspan="3">Maintenance Updates</th>
        </tr>
        <tr>
          <th width="165">Time*</th>
          <th width="165">Logged By</th>
          <th width="400px">Detail</th>
        </tr>
      </thead>

      <tbody>
      {% for row in updates %}
        <tr>
         <td>{{row.date|date:"Y-m-d H:i:s"}}</td>
         <td>{{row.user_id__first_name}} {{row.user_id__last_name}}</td>
         <td>{{row.detail|linebreaksbr}}</td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endif %}
 

<div class="row">
  <div class="large-4 columns">
    <p>*All times are in {{TIME_ZONE}}</p>
  </div>
</div>

{% if user.is_authenticated %}
<div class="row">
  <div class="large-4 columns">
    <div class="horiz_stack">
      <form method="POST" name="m_delete" action="/m_delete">
        {% csrf_token %}
        <input type="hidden" name="id" value="{{id}}">      
        <input type="submit" class="small button" value="delete"/>
      </form>
    </div>
    <div class="horiz_stack">
      <a href="/m_update?id={{id}}" class="small button">update</a>
    </div>
    <div class="horiz_stack">
      <form method="POST" name="m_email" action="/m_email">
        {% csrf_token %}
        <input type="hidden" name="id" value="{{id}}">      
        {% if notifications %}<input type="submit" class="small button" value="email reminder"/>{% endif %}
      </form>
    </div>
  </div>
</div>
{% endif %}

{% endblock %}
